//
//  UIViewController+HUD.m
//  LongCaiApp
//
//  Created by Ajen on 2018/4/2.
//  Copyright © 2018年 Ajen. All rights reserved.
//

#import "UIViewController+HUD.h"

@implementation UIViewController (HUD)
static MBProgressHUD *loadHud;
-(void)loadHUD{
    loadHud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
    loadHud.mode = MBProgressHUDModeIndeterminate;
    loadHud.bezelView.backgroundColor = [UIColor blackColor];
}

-(void)loadHUD:(NSString *)string{
    dispatch_async(dispatch_get_main_queue(), ^{
        loadHud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
        loadHud.mode = MBProgressHUDModeIndeterminate;
//        loadHud.bezelView.backgroundColor = [UIColor blackColor];
        loadHud.labelText = string;
    });
}

-(void)hideLoadHUD{
    dispatch_async(dispatch_get_main_queue(), ^{
        [loadHud hide:YES];
    });
}

-(void)showMsg:(NSString*)msg{
    MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:[UIApplication sharedApplication].keyWindow animated:YES];
    hud.mode = MBProgressHUDModeText;
    hud.label.textColor = [UIColor whiteColor];
    hud.bezelView.backgroundColor = [UIColor blackColor];
    hud.labelText = (msg);
    hud.margin = 25.f;
    hud.yOffset = 100.f;
    hud.removeFromSuperViewOnHide = YES;
    [hud hide:YES afterDelay:1];
}
@end
